#!/usr/bin/env python
"""Create template from OpenFOAM file."""

import argparse
import foampy.templates

parser = argparse.ArgumentParser(description="Create template from OpenFOAM "
                                 "file")
parser.add_argument("file", help="File to convert")
parser.add_argument("--keywords", "-k", help="Keywords to convert inside "
                    "template", nargs="+", default=[])
parser.add_argument("--template-dir", "-d", default="templates",
                    help="Where to put templates")
parser.add_argument("--leave-existing", "-l", default=False,
                    action="store_true", help="Do not delete input file")
parser.add_argument("--git", "-g", default=False, action="store_true",
                    help="Remove input file from Git repo and add to "
                    ".gitignore")
args = parser.parse_args()
foampy.templates.make_template(
    args.file,
    keywords=args.keywords,
    template_dir=args.template_dir,
    git=args.git,
    delete=not args.leave_existing
)
